<template>
	<view class="findPeople">
		<view class="head">
			<view class="search">
				<input type="text" v-model="find" placeholder="找活、找工作" />
				搜索
			</view>
			<view class="classify">

				<view @click="showPopup" class="type">
					<view style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">
						全国
					</view>
					<image src="../../static/下箭头.png"></image>
					<my-tree :ref="popupTree"></my-tree>
				</view>

				<view @click="showPopup" class="type">
					<view style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">
						请选择分类
					</view>
					<image src="../../static/下箭头.png"></image>
					<my-tree :ref="popupTree"></my-tree>
				</view>
				<view @click="showPopup" class="recommend">
					<view style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">
						人员类型
					</view>

					<image src="../../static/下箭头.png"></image>
					<my-tree :ref="popupTree"></my-tree>
				</view>
				<view @click="showPopup" class="recommend">
					<view style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">
						智能推荐
					</view>
					<image src="../../static/下箭头.png"></image>
					<my-tree :ref="popupTree" :Obj="Obj"></my-tree>
				</view>
			</view>
		</view>

		<mescroll-body @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
			<view class="marge">
				<view @click="open">
					<contact-way class="module" style="margin-top: 0rpx;"></contact-way>
					<my-relation ref="popup"></my-relation>
				</view>
				<view class="advisory">
					<view class="advisory-fish">鱼泡资讯：</view>
					<swiper vertical="true" :indicator-dots="false" :autoplay="true" :interval="3000" :duration="1000">
						<swiper-item>
							<view class="swiper-item">Aasdddddddddddddddddddddddddddddddddddddddddd</view>
						</swiper-item>
						<swiper-item>
							<view class="swiper-item">B</view>
						</swiper-item>
					</swiper>
				</view>
			</view>
			<view v-for="(item,index) in dataList" :key="index">
				<view @click="goCallingCard">
					<my-personage :people="item"></my-personage>
				</view>

			</view>
		</mescroll-body>

		<view @click="goRule" :animation="animationData" class="invitation">
			<image src="../../static/找工人_07.jpg"></image>
		</view>
		<view class="job-search">
			发布找活
		</view>
	</view>
</template>

<script>
	import contactWay from '../../components/contactway.vue'
	import myRelation from '../../components/relation.vue'
	import mescrollMixin from '../../components/mescroll-uni/mescroll-mixins.js'
	import mescrollBody from '../../components/mescroll-uni/mescroll-body.vue'
	import myPersonage from '../../components/personage.vue'
	export default {
		mixins: [mescrollMixin],
		data() {
			return {
				animationData: {},
				Obj: [{
						'name': "广州",
						'secondary': ['深圳', '珠海']
					},
					{
						'name': "安徽",
						'secondary': ["安庆", "池州", "巢湖"]
					},
					{
						'name': "测试",
						'secondary': ['深圳', '珠海', "佛山", '深圳', '珠海', "佛山"]
					}
				],
				dataList: [{
						id: 1,
						image: "",
						name: "黎先生",
						sex: "女",
						age: "42",
						label: ["尽职尽责", "吃苦耐劳", "团结协作", "团结协作", "团结协作"],
						typeJob: ["小工/杂工/临时工"],
						text: "测试正文",
						address: "福建厦门",
						profession: "2020-10-25 08:55",
					},
					{
						id: 2,
						image: "",
						name: "",
						sex: "女",
						age: "42",
						label: "",
						nation: "汉族",
						seniority: "工龄15年以上",
						nature: "个人",
						typeJob: ["小工/杂工/临时工"],
						text: "测试正文测试正文测试正文测试正文测试正文测试正文测试正文",
						address: "福建厦门",
						profession: "2020-10-25 08:55",
					}
				]
			}
		},
		components: {
			'contactWay': contactWay,
			'myRelation': myRelation,
			'mescrollBody': mescrollBody,
			'myPersonage': myPersonage
		},
		methods: {
			upCallback(page) {
				let self = this.messages
				let pageNum = page.num; // 页码, 默认从1开始
				let pageSize = page.size; // 页长, 默认每页10条
				let time = 2000;
				uni.request({
					url: 'xxxx?pageNum=' + pageNum + '&pageSize=' + pageSize,
					success: (data) => {
						// 接口返回的当前页数据列表 (数组)
						let curPageData = 2;
						// 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
						let curPageLen = curPageData.length;
						// 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
						let totalPage = 2;
						// 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
						let totalSize = 2;
						// 接口返回的是否有下一页 (true/false)
						let hasNext = false;

						//设置列表数据
						if (page.num == 1) self.messages = []; //如果是第一页需手动置空列表
						self.messages = self.messages.concat(curPageData); //追加新数据

						// 请求成功,隐藏加载状态
						//方法一(推荐): 后台接口有返回列表的总页数 totalPage
						this.mescroll.endByPage(curPageLen, totalPage);

						setTimeout(() => {
							this.mescroll.endSuccess(curPageLen)
						}, 2000)
					},
					fail: () => {
						//  请求失败,隐藏加载状态

						this.mescroll.endErr()
					},
				})

			},
			goCallingCard() {
				uni.navigateTo({
					url: 'callingCard'
				})
			},
			goRule() {
				uni.navigateTo({
					url: 'publish/rule'
				})
			},
			open() {
				this.$refs.popup.$refs.popups.open()
			}
		},
		onPageScroll() {
			let self = this
			this.animation = uni.createAnimation()
			this.animation.translateX(500).step({
				duration: 3000
			})

			this.animationData = this.animation.export()
			setTimeout(() => {
				this.animation.translateX(0).step({
					duration: 3000
				})
				this.animationData = this.animation.export()
			}, 500);

		},
	}
</script>
<style lang="scss">
	// .findPeople {
	// 	.module /deep/ .massage {
	// 		margin-top: 220rpx;
	// 	}
	// }
</style>
<style lang="scss" scoped>
	.findPeople {
		background: #eaeaea;

		.head {
			position: fixed;
			background: #0497ff;
			height: 11vh;
			padding: 50rpx 50rpx 0 20rpx;
			margin-bottom: 30rpx;
			z-index: 8;

			.search {
				display: flex;
				color: #FFFFFF;
				font-size: 32rpx;
				justify-content: space-between;
				align-items: center;
				margin-right: 30rpx;

				input {
					padding-right: 20rpx;
					padding-left: 10rpx;
					background-color: #FFFFFF;
					color: black;
					width: 75vw;
					border-radius: 10rpx;
					height: 60rpx;
				}
			}

			.classify {
				display: flex;
				justify-content: space-between;
				background: #FFFFFF;
				margin-top: 6rpx;
				align-items: center;
				width: 100vw;
				margin-left: -20rpx;
				padding: 0 40rpx;

				image {
					width: 30rpx;
					height: 30rpx;
					margin-left: 10rpx;
				}

				.region,
				.type,
				.recommend {
					display: flex;
					align-items: center;
					justify-content: center;
					width: 20vw;
					height: 6vh;
					white-space: nowrap;

				}
			}
		}

		.marge {
			display: flex;
			flex-direction: column;
			background: #FFFFFF;
			margin-bottom: 20rpx;
			margin-top: 210rpx;

			.advisory {
				height: 6vh;
				display: flex;
				margin-top: 10rpx;
				font-size: 26rpx;
				margin-left: 20rpx;

				.advisory-fish {
					color: #F0AD4E;
					line-height: 40rpx;
				}

				swiper {
					height: 4vh;
					width: 560rpx;

					.swiper-item {
						overflow: hidden;
						text-overflow: ellipsis;
					}
				}
			}
		}

		.invitation {
			display: flex;
			flex-direction: column;
			position: fixed;
			bottom: 20vw;
			right: 40rpx;
			z-index: 5;
			color: #007AFF;
			font-weight: bold;

			image {
				width: 140rpx;
				height: 140rpx;
				border-radius: 20rpx;
				background: #007AFF;
				margin-bottom: 10rpx;
				border-radius: 999rpx;
			}
		}

		.job-search {
			background: #007AFF;
			color: #FFFFFF;
			position: fixed;
			bottom: 3vh;
			left: 34vw;
			font-size: 34rpx;
			line-height: 70rpx;
			padding: 0 60rpx;
			border-radius: 999rpx;
		}
	}
</style>
